package com.namo.cchtool.service.impl;

import com.namo.cchcommon.exception.ApiException;
import com.namo.cchtool.dao.ContactMapper;
import com.namo.cchtool.entity.Contact;
import com.namo.cchtool.service.ContactService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author WangXin
 * @date 2021/5/17 11:16
 */
@Slf4j
@Service
public class ContactServiceImpl implements ContactService {
    @Autowired
    ContactMapper contactMapper;

    @Override
    public List<Contact> getAllContact(){
        try {
            List<Contact> contacts = contactMapper.selectAll();
            log.info("查询到通讯录信息");
            return contacts;
        } catch (Exception e) {
            log.error("查询失败--{}",e.getMessage());
            throw new ApiException(500L,"查询失败",e.getMessage());
        }
    }
}
